<template>
  <el-table :data="tableData" style="width: 100%" height="725px">
    <el-table-column prop="id" label="工作室编号" width="250"></el-table-column>
    <el-table-column
      prop="name"
      label="工作室名称"
      width="250"
    ></el-table-column>
    <el-table-column prop="lable" label="工作室标签"></el-table-column>

    <el-table-column prop="grade" label="评分"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit()">工作室详情</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)"
          >选择该工作室</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      // 工作室
      tableData: [
        {
          id: "",
          name: "",
          lable: "",
          grade: "",
        },
      ],
    };
  },
  mounted: function () {
    let user = JSON.parse(window.sessionStorage.getItem("user"));
    let demandId = JSON.parse(window.sessionStorage.getItem("demandId"));
    // 根据需求id查找参与竞标的工作室
    axios
      .get("http://localhost:88/provider/user/searchWorkroomByDemandId", {
        params: { demandId: demandId },
      })
      .then((response) => {
        if (response.data != null) {
          let e = response.data;
          let data = [];
          for (let c = 0; c < e.length; c++) {
            let ee = e[c];
            let obj = {};
            obj.id = ee.id; //工作室id
            obj.name = ee.workroomName; //工作室名称
            obj.lable = ee.lable; //工作室标签
            obj.grade = ee.grade; //工作室竞标评分
            data[c] = obj;
          }
          this.tableData = data;
        }
      });
  },
  methods: {
    jump(path) {
      this.$router.replace({ path: path });
    },
    handleEdit(index, row) {
      console.log(row.id);
      var ff = row.id;

      axios
        .post("/admin/acceptWorkroomApply", {
          id: ff,
          idd: ff,
        })
        .then((response) => {
          if (response.data.states == 800) {
            this.$notify({
              title: "成功",
              message: "成功",
              type: "success",
              duration: 2000,
            });

            location.reload();
          } else {
            this.$notify({
              title: "失败",
              message: "错误",
              type: "warning",
              duration: 2000,
            });
          }
        });
    },
    handleDelete(index, row) {
      console.log(index, row);
      var ff = row.id;
      axios
        .post("/admin/refuseWorkroomApply", {
          id: ff,
          idd: ff,
        })
        .then((response) => {
          if (response.data.states == 800) {
            this.$notify({
              title: "成功",
              message: "成功",
              type: "success",
              duration: 2000,
            });
            location.reload();
          } else {
            this.$notify({
              title: "失败",
              message: "错误",
              type: "warning",
              duration: 2000,
            });
          }
        });
    },
  },
};
</script>



<style scoped>
</style>
